//
//  UdpManager.h
//  AppFinance
//
//  Created by wei on 12-6-9.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GCDAsyncUdpSocket.h"

#import "AFUdpManagerDelegate.h"

#define K_UDP_MANAGER_NOTIF_LIST @"K_UDP_MANAGER_NOTIF_LIST"
#define K_UDP_MANAGER_NOTIF_DETAIL @"K_UDP_MANAGER_NOTIF_DETAIL"

@interface AFUdpManager : NSObject<GCDAsyncUdpSocketDelegate>
{
    GCDAsyncUdpSocket *udpSocket;
    
    BOOL isUdp;
    
    NSTimer *timer;
    
    long long int lastDataUnixTime;
    
    NSString * udpHost;
}

@property(nonatomic, assign) id <UdpManagerRefreshDelegate> udpManagerRefreshDelegate;

- (void)appActive;
- (void)appBackground;

- (void)udpInit;

- (void)udpStart;
- (void)udpHeartbeat;
- (void)udpEnd;

- (void)startTimer;
- (void)stopTimer;
- (void)onTimer;

- (void)initUdpAndStart:(int)_udpType udpCode:(NSString*)_code withHost:host;

+(AFUdpManager*) udpManager;
@end
 